const _function = require("../../utils/functionData.js")
Page({
  data: {
    clubs: [
      // { id: 1, name: '篮球社', description: '热爱篮球的你，快来加入吧！' },
      // { id: 2, name: '舞蹈社', description: '一起舞动青春，释放激情！' },
      // { id: 3, name: '编程社', description: '学习编程，探索科技的无限可能！' }
    ],
    activities: [
      // { id: 1, name: '篮球友谊赛', description: '与校外队伍进行友谊赛', time: '2025-02-10 14:00' },
      // { id: 2, name: '舞蹈表演', description: '校庆晚会舞蹈表演', time: '2025-02-15 19:00' },
      // { id: 3, name: '编程马拉松', description: '24小时编程挑战赛', time: '2025-02-20 09:00' }
    ],
    _UrlGet_: wx.getStorageSync('img_url')
  },
  onLoad() {
    this.getSocietyList()
    this.getActivitiesList()
  },

  onShow() {
    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
      this.getTabBar().setData({
        selected: 3  //这个数字是当前页面在tabBar中list数组的索引
      })
    }
  },
  // 获取社团列表
  getSocietyList() {
    console.log('获取聊天列表');
    _function.getSocietyList(this.data.param, this.getSocietyListBack, this)
  },
  getSocietyListBack(res) {
    let dataAll = res.data
    if (dataAll.code == 200) {
      this.setData({
        clubs: dataAll.rows
      })
      console.log('社团列表', dataAll.rows);
    }
  },
  // 社团活动列表
  getActivitiesList() {
    console.log('获取聊天列表');
    _function.getActivitiesList(this.data.param, this.getActivitiesListBack, this)
  },
  getActivitiesListBack(res) {
    let dataAll = res.data
    if (dataAll.code == 200) {
      this.setData({
        activities: dataAll.rows
      })
      console.log('社团活动列表', dataAll.rows);
    }
  },
  goActivityDetail(e) {
    const id = e.currentTarget.dataset.id; // 获取 data-id 
    wx.navigateTo({
      url: '/pages/activitydetail/activitydetail?id=' + id,
    })
  },
  goClubDetail(e) {
    console.log('e', e);
    const id = e.currentTarget.dataset.id; // 获取 data-id 
    wx.navigateTo({
      url: '/pages/clubdetail/clubdetail?id=' + id,
    })
  }
});